package scu.maqiang.numeric;

import static java.lang.Math.sqrt;

/**
  * 常数类，记录存储有限元分析计算过程中各种不变常数
 * 
 * @author 马强
 *
 */
public class Constants {
	/**
	 * 全局容许误差值
	 */
	public static final double Er = 1.0e-30;

	/**
	 * 1阶精度高斯积分点
	 */
	public static final double[] GP1 = { 0.0 };
	/**
	 * 1阶精度高斯积分权重
	 */
	public static final double[] GW1 = { 2.0 };

	/**
	 * 3阶精度高斯积分点
	 */
	public static final double[] GP2 = { -1.0 / sqrt(3.0), 1.0 / sqrt(3.0) };

	/**
	 * 3阶精度高斯积分权重
	 */
	public static final double[] GW2 = { 1.0, 1.0 };

	/**
	 * 5阶精度高斯积分点
	 */
	public static final double[] GP3 = { 0.77459_66692_41483, -0.77459_66692_41483, 0.0 };

	/**
	 * 5阶精度高斯积分点
	 */
	public static final double[] GW3 = { 0.55555_55555_55556, 0.55555_55555_55556, 0.88888_88888_88889 };

	/**
	 * 7阶精度高斯积分点
	 */
	public static final double[] GP4 = { 0.86113_63115_94053, -0.86113_63115_94053, 0.33998_10435_84856,
			-0.33998_10435_84856 };

	/**
	 * 7阶精度高斯积分权重
	 */
	public static final double[] GW4 = { 0.34785_48451_37454, 0.34785_48451_37454, 0.65214_51548_62546,
			0.65214_51548_62546 };

	/**
	 * 9阶精度高斯积分点
	 */
	public static final double[] GP5 = { 0.90617_98459_38664, -0.90617_98459_38664, 0.53846_93101_05683,
			-0.53846_93101_05683, 0.0 };

	/**
	 * 9阶精度高斯积分权重
	 */
	public static final double[] GW5 = { 0.23692_68850_56189, 0.23692_68850_56189, 0.47862_86704_99366,
			0.47862_86704_99366, 0.56888_88888_88889 };

	/**
	 * 11阶精度高斯积分点
	 */
	public static final double[] GP6 = { 0.93246_95142_03152, -0.93246_95142_03152, 0.66120_93864_66265,
			-0.66120_93864_66265, 0.23861_91860_83197, -0.23861_91860_83197 };

	/**
	 * 11阶精度高斯积分权重
	 */
	public static final double[] GW6 = { 0.17132_44923_79170, 0.17132_44923_79170, 0.36076_15730_48139,
			0.36076_15730_48139, 0.46791_39345_72691, 0.46791_39345_72691};
	
	public static final double[][][] GaussQuadratureConstants = {{GP1, GW1},{GP2, GW2}, {GP3, GW3},
																 {GP4, GW4},{GP5, GW5}, {GP6, GW6}};
	/**
	 * 1阶精度三角形积分点
	 */
	public static final double[] TP1 = { 0.333333333333333, 0.333333333333334, 0.333333333333333 };

	/**
	 * 1阶精度三角形积分权系数
	 */
	public static final double[] TW1 = { 1.0 };

	/**
	 * 2阶精度三角形积分点
	 */
	public static final double[][] TP2 = { { 0.5, 0.5, 0.0 }, { 0.5, 0.0, 0.5 }, { 0.0, 0.5, 0.5 } };
	/**
	 * 2阶精度三角形积分权系数
	 */
	public static final double[] TW2 = { 0.333333333333333, 0.333333333333334, 0.333333333333333 };

	/**
	 * 3阶精度三角形积分点
	 */
	public static final double[][] TP3 = { { 0.333333333333333, 0.333333333333334, 0.333333333333333 },
			{ 0.6, 0.2, 0.2 }, { 0.2, 0.6, 0.2 }, { 0.2, 0.2, 0.6 } };

	/**
	 * 3阶精度三角形积分权系数
	 */
	public static final double[] TW3 = { -0.5625, 0.52083333333333333, 0.520833333333334, 0.520833333333333 };

	private static final double al1 = 0.0597158717;
	private static final double be1 = 0.4701420641;
	private static final double al2 = 0.7974269853;
	private static final double be2 = 0.1012865073;

	/**
	 * 4阶精度三角形积分点
	 */
	public static final double[][] TP4 = { { 0.333333333333333, 0.333333333333334, 0.333333333333333 },
			{ al1, be1, be1 }, { be1, al1, be1 }, { be1, be1, al1 }, { al2, be2, be2 }, { be2, al2, be2 },
			{ be2, be2, al2 } };
	/**
	 * 4阶精度三角形积分权系数
	 */
	public static final double[] TW4 = { 0.225, 0.1323941527, 0.1323941527, 0.1323941527, 0.1259391805, 0.1259391805,
			0.1259391805 };


	/**
	 * 4阶精度三角形积分点
	 */
	public static final double[][] TP5 = {{ 0.333333333333333, 0.333333333333334, 0.333333333333333 }, 
            {0.059_715_8718, 0.470_142_0641, 0.470_142_0641},
            {0.470_142_0641, 0.059_715_8718, 0.470_142_0641},
            {0.470_142_0641, 0.470_142_0641, 0.059_715_8718},
            {0.797_426_9854, 0.101_286_5073, 0.101_286_5073},
            {0.101_286_5073, 0.797_426_9854, 0.101_286_5073},
            {0.101_286_5073, 0.101_286_5073, 0.797_426_9854}};
	/**
	 * 5阶精度三角形积分权系数
	 */
	public static final double[] TW5 = {0.225, 0.132_394_1527, 0.132_394_1527, 0.132_394_1527, 0.125_939_1805, 0.125_939_1805, 0.125_939_1805};


	/**
	 * 1阶精度四面体积分点
	 */
	public static final double[] TetP = {0.25, 0.25, 0.25, 0.25};
	
	/**
	 * 1阶精度四面体积分权系数
	 */
	public static final double[] TetW = {1.0};

	private static final double al = 0.58541020;
	private static final double be = 0.13819660;
	
	/**
	 * 2阶精度四面体积分点
	 */
	public static final double[][] TetP2 = {{al, be, be, be}, 
	                                                  {be, al, be, be},
	                                                  {be, be, al, be}, 
	                                                  {be, be, be, al}};
	/**
	 * 2阶精度四面体积分权系数
	 */
	public static final double[] TetW2 = {0.25, 0.25, 0.25, 0.25};

	/**
	 * 3阶精度四面体积分点
	 */
	public static final double[][]  TetP3 = {{0.25, 0.25, 0.25, 0.25}, 
			{0.5, 0.1666666667, 0.1666666666, 0.1666666667},
	        {0.1666666667, 0.5, 0.1666666666, 0.1666666667},
	        {0.1666666667, 0.1666666666, 0.5, 0.1666666667}, 
	        {0.1666666667, 0.1666666666, 0.1666666667, 0.5}};
	
	/**
	 * 3阶精度四面体积分权系数
	 */
	public static final double[] TetW3 = {-0.8, 0.45, 0.45, 0.45, 0.45};
	
	private static final double A = 1 + 0.5 * Math.sqrt(3);
	private static final double B = -0.5;
	private static final double C = 1 - 0.5 * Math.sqrt(3);

	public static final double[][] GaussMatrix2D = new double[][] { { A, B, B, C }, { B, C, A, B }, { C, B, B, A },
			{ B, A, C, B } };

	private static final double epA = 1.683012701892219;
	private static final double epB = -0.683012701892219;
	private static final double epC = 0.183012701892219;
	private static final double epD = 0.816987298107781;
	public static final double[][] GaussMatrix3D = { { epA, epB, epC, epB, epB, epC, epD, epC },
			{ epB, epC, epD, epC, epA, epB, epC, epB }, { epB, epC, epB, epA, epC, epD, epC, epB },
			{ epC, epD, epC, epB, epB, epC, epB, epA }, { epB, epA, epB, epC, epC, epB, epC, epD },
			{ epC, epB, epC, epD, epB, epA, epB, epC }, { epC, epB, epA, epB, epD, epC, epB, epC },
			{ epD, epC, epB, epC, epC, epB, epA, epB } };

}